package com.cskaoyan.market.controller;

import com.cskaoyan.market.service.WxCommentService;
import com.cskaoyan.market.util.ResponseUtil;
import com.cskaoyan.market.vo.CommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * @author Wisteria
 * @version 1.0
 * @description:
 * @date 2023-04-03 19:18
 */

@RestController
@RequestMapping("wx/comment")
public class WxCommentController {

    @Autowired
    WxCommentService wxCommentService;
    @GetMapping("list")
    public Object displayList(Integer valueId,Byte type,Integer limit,Integer page,Integer showType){
        List<CommentVo> commentVoList=wxCommentService.list(page,limit,valueId,type);
        return ResponseUtil.okList(commentVoList);
    }

    @GetMapping("count")
    public Object countComment(Integer valueId,Byte type){
        Map<String,Long> result=wxCommentService.count(valueId,type);
        return ResponseUtil.ok(result);
    }

    @PostMapping("post")
    public Object addComment(@RequestBody Map<String,String> map){
        String content = map.get("content");
        boolean hasPicture = Boolean.parseBoolean(map.get("hasPicture"));
        Integer star=Integer.parseInt(map.get("star"));
        Integer valueId=Integer.parseInt(map.get("valueId"));
        Byte type = Byte.parseByte(map.get("type")) ;
        System.out.println(map.get("picUrls"));

        return ResponseUtil.ok();
    }
}
